package exception;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //捕获异常
        int[] arr={1,2,3};

        try{
            System.out.println("before");
            arr=null;
            System.out.println(arr[100]);
            System.out.println("after");

        }catch(ArrayIndexOutOfBoundsException e){
            System.out.println("这是个数组下标异常越界");
            e.printStackTrace();
        }catch (NullPointerException e){
            System.out.println("这是个空指针异常");
            e.printStackTrace();
        }finally {
            System.out.println("after try catch");
        }

//        try(Scanner sc=new Scanner(System.in)){
//            int num=sc.nextInt();
//            System.out.println("num="+num);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
    }

}
